<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="base" uri="/WEB-INF/mytags.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>分类列表</title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<jsp:include page="../include.jsp" />
<style>
.bar .site {
	float: right;
}

.select {
	margin-right: 20px;
}

#tree {
	float: left;
	width: 15%;
}

#table {
	float: right;
	width: 84%;
	border-left: 1px solid #CCCCCC;
}

#middle {
	padding: 0;
	float: left;
	width: 1px;
	background: #D8DEEA;
	height: 400px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
	  if(${fn:length(result)}==0){
		  $("#tree").css("display","none");
		  $("#middle").css("display","none");
		  $("#table").css("width","100%");
	  }
	  $("#model_id").change(function(){
	     if(this.value==-2){
			 window.location="../../modelAction/model/list.do";
			 return;
		 } 
		 if(this.value!=-1){
			 window.location="beforeAdd.do?site_id="+$("#site_id").val()+"&model_id="+$("#model_id").val()+"&model_type=1";
		 }
		
	  });
	  
	  $("[href='#']").click(function(){
		  
		  var $this = $(this);
		  var url = $this.attr("url");
		  window.location=url+"&site_id="+$("#site_id").val();
	  });
});
</script>
</head>
<body class="list">
<div class="bar">分类列表&nbsp;总记录数: ${fn:length(channels)}
	<div class="site">站点: 
		<select name="site_id" class="select" id="site_id">
			<c:forEach items="${sites}" var="site">
				<option value="${site.key}">${site.value}</option>
			</c:forEach>
		</select>
		栏目模型: 
		<select name="model_id" class="select" id="model_id">
			<option value="-1">--选择模型--</option>
			<c:forEach items="${models}" var="model">
				<option value="${model.key}">${model.value}</option>
			</c:forEach>
			<c:if test="${fn:length(models)==0}">
				<option value="-2">添加模型</option>
			</c:if>
		</select>
	</div>
</div>
<div class="body">
<div id="table">
<form id="listForm" action="module.do" method="post">
<table id="listTable" class="listTable">
	<tr>
		<th class="check"><input type="checkbox" class="allCheck" /></th>
		<th><a href="#" class="sort" name="name" hidefocus>ID</a></th>
		<th><a href="#" class="sort" name="name" hidefocus>名称</a></th>
		<th><a href="#" class="sort" name="path" hidefocus>访问路径</a></th>
		<th><a href="#" class="sort" name="priority" hidefocus>排列顺序</a></th>
		<th><a href="#" class="sort" name="display" hidefocus>是否显示</a></th>
		<th><span>操作</span></th>
	</tr>
	<c:forEach items="${channels}" var="channel">
		<tr>
			<td><input type="checkbox" name="ids" value="${channel.channel_id}" />
			</td>
			<td>${channel.channel_id}</td>
			<td>${channel.channel_name}[<span style="color:red">${base:getMapValue(models,channel.model_id)}</span>]</td>
			<td>${channel.channel_path}</td>
			<td>${channel.priority}</td>
			<td>${channel.is_display}</td>
			<td><a href="#" url="edit.do?id=${channel.channel_id}&model_id=${channel.model_id}&model_type=1" title="修改" id="edit">[修改]</a></td>
		</tr>
	</c:forEach>
</table>
<c:choose>
	<c:when test="${fn:length(channels)==0}">
		<div class="noRecord">没有找到任何记录!</div>
	</c:when>
	<c:otherwise>
		<div class="delete" style="padding-left: 10px"><input
			type="button" id="deleteButton" class="formButton" url="delete.do"
			value="删除" disabled hidefocus /></div>
	</c:otherwise>
</c:choose></form>
</div>
</div>
</body>
</html>